<?php

namespace apiend\modules\user\controllers;

use Yii;
use apiend\components\Controller;

/**
 * 课程浏览记录
 * Default controller for the `user` module
 */
class HistoryController extends Controller {

    public $modelClass = 'apiend\modules\user\models\HistoryCourseSearch';

    /**
     * @inheritdoc
     */
    protected function rules() {
        return [
            [
                'allow' => true,
                'roles' => ['@'],
            ],
        ];
    }

    /**
     * @inheritdoc
     */
    protected function verbs() {
        return [
            '*' => ['GET'],
        ];
    }

    /**
     * 根据分类ID检索课程列表
     * @inheritdoc
     */
    public function actionIndex() {
        /* @var $modelClass \apiend\modules\user\models\HistoryCourseSearch */
        $modelClass = new $this->modelClass;
        return $modelClass->search($this->token->user_id);
    }

}
